package com.yanqu.road.server.manager.activity.langyabang.log;

import com.yanqu.road.entity.log.langyabang.*;
import com.yanqu.road.logic.bussiness.log.LogBussiness;

import java.util.ArrayList;
import java.util.List;

public class LogCrossLangYaBang {


    public static void save() {
        saveLogLangYaBangUpgradeBuildings();
        saveLogLangYaBangDraw();
        saveLogLangYaBangDaiZheng();
        saveLogLangYaBangPve();
        saveLogLangYaBangPvp();
    }


    public static List<LogLangYaBangUpgradeBuilding> logLangYaBangUpgradeBuildings = new ArrayList<>();
    public static List<LogLangYaBangDraw> logLangYaBangDraws = new ArrayList<>();
    public static List<LogLangYaBangDaiZheng> logLangYaBangDaiZhengs = new ArrayList<>();
    public static List<LogLangYaBangPve> logLangYaBangPves = new ArrayList<>();
    public static List<LogLangYaBangPvp> logLangYaBangPvps = new ArrayList<>();

    public static void addLogLangYaBangDraw(LogLangYaBangDraw logLangYaBangDraw){
        synchronized (logLangYaBangDraws){
            logLangYaBangDraws.add(logLangYaBangDraw);
        }
    }

    public static void saveLogLangYaBangDraw(){
        List<LogLangYaBangDraw> list;
        synchronized (logLangYaBangDraws){
            list = new ArrayList<>(logLangYaBangDraws);
            logLangYaBangDraws.clear();
        }
        if (list.isEmpty()){
            return;
        }
        LogBussiness.addLogLangYaBangDrawList(list);
    }

    public static void addLogLangYaBangUpgradeBuildings(LogLangYaBangUpgradeBuilding log){
        synchronized (logLangYaBangUpgradeBuildings){
            logLangYaBangUpgradeBuildings.add(log);
        }
    }

    public static void saveLogLangYaBangUpgradeBuildings(){
        List<LogLangYaBangUpgradeBuilding> list;
        synchronized (logLangYaBangUpgradeBuildings){
            list = new ArrayList<>(logLangYaBangUpgradeBuildings);
            logLangYaBangUpgradeBuildings.clear();
        }
        if (list.isEmpty()){
            return;
        }
        LogBussiness.addLogLangYaBangUpgradeBuildingList(list);
    }

    public static void addLogLangYaBangDaiZheng(LogLangYaBangDaiZheng log){
        synchronized (logLangYaBangDaiZhengs){
            logLangYaBangDaiZhengs.add(log);
        }
    }

    public static void saveLogLangYaBangDaiZheng(){
        List<LogLangYaBangDaiZheng> list;
        synchronized (logLangYaBangDaiZhengs){
            list = new ArrayList<>(logLangYaBangDaiZhengs);
            logLangYaBangDaiZhengs.clear();
        }
        if (list.isEmpty()){
            return;
        }
        LogBussiness.addLogLangYaBangDaiZhengList(list);
    }

    public static void addLogLangYaBangPve(LogLangYaBangPve log){
        synchronized (logLangYaBangPves){
            logLangYaBangPves.add(log);
        }
    }

    public static void saveLogLangYaBangPve(){
        List<LogLangYaBangPve> list;
        synchronized (logLangYaBangPves){
            list = new ArrayList<>(logLangYaBangPves);
            logLangYaBangPves.clear();
        }
        if (list.isEmpty()){
            return;
        }
        LogBussiness.addLogLangYaBangPveList(list);
    }

    public static void addLogLangYaBangPvp(LogLangYaBangPvp logLangYaBangPvp){
        synchronized (logLangYaBangPvps){
            logLangYaBangPvps.add(logLangYaBangPvp);
        }
    }

    public static void saveLogLangYaBangPvp(){
        List<LogLangYaBangPvp> list;
        synchronized (logLangYaBangPvps){
            list = new ArrayList<>(logLangYaBangPvps);
            logLangYaBangPvps.clear();
        }
        if (list.isEmpty()){
            return;
        }
        LogBussiness.addLogLangYaBangPvpList(list);
    }

}
